{{extend "func_demo_layout.html"}}

{{block sidemenu}}
{{<< sidemenu('FUNCMENU', 'generic', 'list')}}
{{end}}

{{block content_main}}
<!-- 引入 ui.ag-grid -->
{{use "ui.ag-grid"}}
<!-- 引入 grid.js (包含ag-grid tag)-->
{{link "modules/ag-grid/tags/grid.js"}}
<!-- 引入查询条件 -->
{{use "ui.query_condition"}}

<query-condition></query-condition>

<div class="tools">
  <a class="btn btn-flat btn-primary btn-sm" href="/func/add" id="btnAdd"><i class="fa fa-plus"></i> 新增</a>
  <a class="btn btn-flat btn-primary btn-sm" href="/func/add1" id="btnAddDialog"><i class="fa fa-plus"></i> 新增(对话框)</a>
</div>
<ag-grid></ag-grid>
<div class="clearfix tools">
  <div class="pull-right">
    <a class="btn btn-flat btn-info btn-sm" href="{{<< table.download_url()}}">下载</a>
  </div>
  <div id="pagination" class="pull-left"></div>
</div>

<script>
    var gridOptions = {
        columnDefs: {{<< json_dumps(table.table_info['fields_list'])}},
        //rowData: rowData

        //以下几个是用于分页的配置项
        total: {{=total}},
        pageRows: 2,
        //自动撑满
        autoFit: true,
        //pagination: '#pagination
        url: "{{<< table.data_url}}"

    };

    riot.mount('ag-grid', {options:gridOptions})

    var query = {{<< json_dumps(query_form)}}
    riot.mount('query-condition', query)

    $(function(){
      $('#btnAddDialog').click(function(e){
        e.preventDefault();
        dialog($(this).attr('href'));
      });
    });

</script>
{{end}}
